<template>
  <div class="slide">
    <div class="slideshow">
      <transition-group
        tag="ul"
        name="image"
        :style="{ width: pages.length * 800 + 'px' }"
        class="urlStyle"
      >
        <li
          v-for="(page, index) in pages"
          v-show="index === mark"
          :key="index + '__index'"
        >
          <img class="bg" :src="page.backgroundImage.url" />
          <span class="page_name">{{ page.pageName }}</span>
          <span
            class="onekey"
            :style="{ background: 'url(' + resourcePath + 'onekey.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          ></span>
          <input
            class="ckeck_license"
            type="checkbox"
            name="ckeck_license"
            checked="checked"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          />
          <span
            class="tongyi"
            :style="{ background: 'url(' + resourcePath + 'tongyi.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          ></span>
          <span
            class="xieyi"
            :style="{ background: 'url(' + resourcePath + 'yonghuxieyi.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          ></span>
          <span
            class="browse"
            :style="{ background: 'url(' + resourcePath + 'browse.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          ></span>
          <span
            class="btn_next"
            :style="{ background: 'url(' + resourcePath + 'btn_next.bmp)' }"
            v-if="
              page.backgroundImage.nsisUseName == 'installPage_database.bmp'
            "
          ></span>
          <span
            class="btn_quit"
            :style="{ background: 'url(' + resourcePath + 'btn_quit.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'upgradePage_first.bmp'"
          ></span>
          <span
            class="btn_cancel"
            :style="{ background: 'url(' + resourcePath + 'btn_cancel.bmp)' }"
            v-if="page.backgroundImage.nsisUseName == 'upgradePage_first.bmp'"
          ></span>
          <span
            class="full_bg"
            :style="{ background: 'url(' + resourcePath + 'full_bg.bmp)' }"
            v-if="page.pageType == '1'"
          ></span>
          <span
            class="express"
            :style="{ background: 'url(' + resourcePath + 'express.bmp)' }"
            v-if="
              page.backgroundImage.nsisUseName == 'installPage_complete.bmp' ||
                page.backgroundImage.nsisUseName == 'upgradePage_complete.bmp'
            "
          ></span>
          <input
            class="install_path"
            value="C:\Program Files\MyApp"
            v-if="page.backgroundImage.nsisUseName == 'installPage_first.bmp'"
          />
        </li>
      </transition-group>
    </div>
    <div class="bar">
      <span
        v-for="(item, index) in pages"
        :class="{ active: index === mark }"
        @click="change(index)"
        :key="index"
      ></span>
    </div>
  </div>
</template>

<script scoped>
export default {
  name: "preview",
  data() {
    return {
      slideList: [
        {
          clickUrl: "#",
          desc: "nhwc",
          image: "http://dummyimage.com/1745x492/f1d65b"
        },
        {
          clickUrl: "#",
          desc: "hxrj",
          image: "http://dummyimage.com/1745x492/40b7ea"
        },
        {
          clickUrl: "#",
          desc: "rsdh",
          image: "http://dummyimage.com/1745x492/e3c933"
        }
      ],
      currentIndex: 0,
      timer: "",
      mark: 0,
      stayTime: 2000
    };
  },
  methods: {
    autoPlay() {
      this.mark++;
      if (this.mark === this.pages.length) {
        this.mark = 0;
      }
      this.stayTime = this.$store.state.productInfo[
        this.$store.state.activeOption
      ].pages.page[this.mark].stayTime;
      if (!this.stayTime) this.stayTime = 2000;
      this.stayTime = this.stayTime * 2;
      clearInterval(this.timer);
      this.timer = setInterval(this.autoPlay, this.stayTime);
    },
    play() {
      this.timer = setInterval(this.autoPlay, this.stayTime);
    },
    change(i) {
      this.mark = i;
    },
    stop() {
      clearInterval(this.timer);
    },
    move() {
      this.timer = setInterval(this.autoPlay, 2500);
    }
  },
  created() {
    //this.play();
  },
  computed: {
    pages() {
      return this.$store.state.productInfo[this.$store.state.activeOption].pages
        .page;
    },
    resourcePath() {
      return (
        "/magicflu/buildpackage/target/" +
        this.$store.state.spaceId +
        "/" +
        this.$store.state.productInfo.id +
        "/"
      );
    }
  }
};
</script>

<style scoped>
.slide {
  width: 560px;
  height: 420px;
  margin: 0 auto;
  /*margin-top: 50px;*/
  /*overflow: hidden;*/
  position: relative;
  margin-bottom: 20px;
}
.urlStyle {
  overflow: hidden;
}
.slideshow {
  width: 800px;
  height: 600px;
  transform: scale(0.7) translate(-21.5%, -22%);
}
li {
  width: 800px;
  height: 600px;
  position: relative;
  list-style: none;
  float: left;
}
.bg {
  width: 800px;
  height: 600px;
}
.page_name {
  font-size: 25px;
  color: #fff;
  position: absolute;
  top: 5px;
  width: 100%;
  display: inline-block;
  text-align: center;
}
.onekey {
  width: 228px;
  height: 70px;
  position: absolute;
  top: 447px;
  left: 290px;
}
.ckeck_license {
  width: 14px;
  height: 14px;
  position: absolute;
  left: 20px;
  top: 551px;
}
.tongyi {
  width: 32px;
  height: 16px;
  position: absolute;
  left: 42px;
  top: 551px;
}
.xieyi {
  width: 128px;
  height: 16px;
  position: absolute;
  left: 80px;
  top: 551px;
}
.btn_next {
  width: 88px;
  height: 30px;
  position: absolute;
  left: 656px;
  top: 551px;
}
.btn_quit {
  width: 113px;
  height: 37px;
  position: absolute;
  left: 250px;
  top: 451px;
}
.btn_cancel {
  width: 113px;
  height: 37px;
  position: absolute;
  left: 450px;
  top: 451px;
}
.full_bg {
  width: 800px;
  height: 10px;
  position: absolute;
  left: 0px;
  top: 588px;
  background-repeat: no-repeat;
}
.express {
  width: 228px;
  height: 70px;
  position: absolute;
  left: 290px;
  top: 478px;
  /*display:inline-block;
    background-color: #ffffff;
    box-shadow: 0px 2px 5px 0px 
    rgba(0, 0, 0, 0.24);
    border-radius: 30px;
    font-family: STYuanti-SC-Light;
    font-size: 24px;
    font-weight: normal;
    font-stretch: normal;
    line-height: 60px;
    letter-spacing: 2px;
    color: #ff6f59;
    text-align: center;
    */
}
.browse {
  width: 84px;
  height: 26px;
  position: absolute;
  left: 656px;
  top: 551px;
}
.install_path {
  width: 367px;
  height: 24px;
  background-color: #f2f4f5;
  border-radius: 5px 0px 0px 5px;
  border: solid 1px #c4c4c4;
  position: absolute;
  left: 289px;
  top: 551px;
}
.bar {
  position: absolute;
  width: 100%;
  bottom: -20px;
  margin: 0 auto;
  z-index: 10;
  text-align: center;
}
.bar span {
  width: 20px;
  height: 5px;
  border: 1px solid;
  background: white;
  display: inline-block;
  margin-right: 10px;
}
.active {
  background: red !important;
}

.image-enter-active {
  transform: translateX(0);
  transition: all 1.5s ease;
}
.image-leave-active {
  transform: translateX(-100%);
  transition: all 1.5s ease;
}
.image-enter {
  transform: translateX(100%);
}
.image-leave {
  transform: translateX(0);
}
</style>
